#!/usr/bin/python
#coding:utf-8
import requests
import json
import configparser
import os

con = configparser.ConfigParser()
con.read("config.ini")
URL = con.get("address","url")
TYPE = con.get("types","type")
FILE = con.get("files","file")

def postAndReturnJson(line):
    data = {'text':line.strip("\n")}
    response = requests.post(URL,data = data)
    respJson = json.loads(response.text)
    return respJson
    
def postAndReturnJsonTest(line):
    response = '{"result": [{"a":"aa","b":"nay","c":"cc"}]}'
    respJson = json.loads(response)
    return respJson

def ner(content):
    list = []
    for line in content:
        respJson = postAndReturnJsonTest(line)
        if not (TYPE in respJson["result"][-1].values()):
            list.append(line)
    return list

def readFile(path):
    with open(path, 'r') as f:
        return f.readlines()

if __name__ == "__main__":
    lines = readFile(FILE)  #读文件
    list = ner(lines)  #判断是否实体识别返回
    for i in list:
        print "%s is not ner" % json.dumps(i, ensure_ascii=False, encoding='UTF-8')